package com.ruoyi.pump.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.pump.domain.TPump;
import com.ruoyi.pump.service.ITPumpService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 泵组信息Controller
 * 
 * @author ruoyi
 * @date 2025-09-18
 */
@RestController
@RequestMapping("/pump/pump")
public class TPumpController extends BaseController
{
    @Autowired
    private ITPumpService tPumpService;

    /**
     * 查询泵组信息列表
     */
    @PreAuthorize("@ss.hasPermi('pump:pump:list')")
    @GetMapping("/list")
    public TableDataInfo list(TPump tPump)
    {
        startPage();
        List<TPump> list = tPumpService.selectTPumpList(tPump);
        return getDataTable(list);
    }

    /**
     * 导出泵组信息列表
     */
    @PreAuthorize("@ss.hasPermi('pump:pump:export')")
    @Log(title = "泵组信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TPump tPump)
    {
        List<TPump> list = tPumpService.selectTPumpList(tPump);
        ExcelUtil<TPump> util = new ExcelUtil<TPump>(TPump.class);
        util.exportExcel(response, list, "泵组信息数据");
    }

    /**
     * 获取泵组信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('pump:pump:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tPumpService.selectTPumpById(id));
    }

    /**
     * 新增泵组信息
     */
    @PreAuthorize("@ss.hasPermi('pump:pump:add')")
    @Log(title = "泵组信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TPump tPump)
    {
        return toAjax(tPumpService.insertTPump(tPump));
    }

    /**
     * 修改泵组信息
     */
    @PreAuthorize("@ss.hasPermi('pump:pump:edit')")
    @Log(title = "泵组信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TPump tPump)
    {
        return toAjax(tPumpService.updateTPump(tPump));
    }

    /**
     * 删除泵组信息
     */
    @PreAuthorize("@ss.hasPermi('pump:pump:remove')")
    @Log(title = "泵组信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tPumpService.deleteTPumpByIds(ids));
    }
}
